home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / VIEWERS / PWBROWSE / PRINT.FRM < prev    next >
Text File  |  1993-11-08  |  10KB  |  309 lines

  1. VERSION 2.00
  2. Begin Form frmPrint 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Print Version Information"
  6.    ClientHeight    =   2190
  7.    ClientLeft      =   3600
  8.    ClientTop       =   2115
  9.    ClientWidth     =   6330
  10.    Height          =   2655
  11.    Left            =   3510
  12.    LinkTopic       =   "Form2"
  13.    ScaleHeight     =   2190
  14.    ScaleWidth      =   6330
  15.    Top             =   1740
  16.    Width           =   6510
  17.    Begin CommonDialog cdFont 
  18.       Left            =   3840
  19.       Top             =   1800
  20.    End
  21.    Begin CommandButton cbFont 
  22.       Caption         =   "Select &Font ..."
  23.       Height          =   375
  24.       Left            =   2280
  25.       TabIndex        =   5
  26.       Top             =   1680
  27.       Width           =   1455
  28.    End
  29.    Begin Frame Frame1 
  30.       BackColor       =   &H00C0C0C0&
  31.       Caption         =   "Print What"
  32.       Height          =   1095
  33.       Left            =   120
  34.       TabIndex        =   4
  35.       Top             =   960
  36.       Width           =   1935
  37.       Begin OptionButton obDirectory 
  38.          BackColor       =   &H00C0C0C0&
  39.          Caption         =   "&Entire Directory"
  40.          Height          =   255
  41.          Left            =   120
  42.          TabIndex        =   11
  43.          Top             =   720
  44.          Width           =   1695
  45.       End
  46.       Begin OptionButton obSelected 
  47.          BackColor       =   &H00C0C0C0&
  48.          Caption         =   "&Selected Files"
  49.          Height          =   255
  50.          Left            =   120
  51.          TabIndex        =   10
  52.          Top             =   360
  53.          Value           =   -1  'True
  54.          Width           =   1575
  55.       End
  56.    End
  57.    Begin CommandButton cbCancel 
  58.       Cancel          =   -1  'True
  59.       Caption         =   "Cancel"
  60.       Height          =   375
  61.       Left            =   4440
  62.       TabIndex        =   3
  63.       Top             =   1680
  64.       Width           =   735
  65.    End
  66.    Begin CommandButton cbOK 
  67.       Caption         =   "OK"
  68.       Default         =   -1  'True
  69.       Height          =   375
  70.       Left            =   5400
  71.       TabIndex        =   2
  72.       Top             =   1680
  73.       Width           =   735
  74.    End
  75.    Begin TextBox tbTitle 
  76.       Height          =   285
  77.       Left            =   1320
  78.       TabIndex        =   1
  79.       Top             =   240
  80.       Width           =   4935
  81.    End
  82.    Begin Label lblDir 
  83.       BackStyle       =   0  'Transparent
  84.       Height          =   255
  85.       Left            =   1080
  86.       TabIndex        =   9
  87.       Top             =   720
  88.       Width           =   5175
  89.    End
  90.    Begin Label Label3 
  91.       Alignment       =   1  'Right Justify
  92.       BackStyle       =   0  'Transparent
  93.       Caption         =   "Directory:"
  94.       Height          =   255
  95.       Left            =   0
  96.       TabIndex        =   8
  97.       Top             =   720
  98.       Width           =   975
  99.    End
  100.    Begin Label Label2 
  101.       BackStyle       =   0  'Transparent
  102.       Caption         =   "Current Font:"
  103.       Height          =   255
  104.       Left            =   2280
  105.       TabIndex        =   7
  106.       Top             =   1080
  107.       Width           =   1335
  108.    End
  109.    Begin Label lblFont 
  110.       BackStyle       =   0  'Transparent
  111.       Height          =   255
  112.       Left            =   2280
  113.       TabIndex        =   6
  114.       Top             =   1320
  115.       Width           =   3855
  116.    End
  117.    Begin Label Label1 
  118.       Alignment       =   1  'Right Justify
  119.       BackStyle       =   0  'Transparent
  120.       Caption         =   "Report &Title:"
  121.       Height          =   255
  122.       Left            =   0
  123.       TabIndex        =   0
  124.       Top             =   240
  125.       Width           =   1215
  126.    End
  127. End
  128. Dim IDs(16) As String
  129. Dim IDLen(16) As Integer
  130. Dim MaxLen As Integer
  131. Dim LineHeight As Integer
  132.  
  133. Sub cbCancel_Click ()
  134.     Unload frmPrint
  135. End Sub
  136.  
  137. Sub cbFont_Click ()
  138.     Const CF_EFFECTS = &H200
  139.     Const CF_PRINTERFONTS = &H2
  140.     Const CF_FORCEFONTEXIST = &H10000
  141.     
  142.     cdFont.FontName = Printer.FontName
  143.     cdFont.Flags = CF_EFFECTS Or CF_PRINTERFONTS Or CF_FORCEFONTEXIST
  144.     cdFont.Action = 4 ' get font
  145.     lblFont.Caption = cdFont.FontName
  146.     Printer.FontName = cdFont.FontName
  147.     MaxLen = 0 ' invalidate width information
  148. End Sub
  149.  
  150. Sub cbOK_Click ()
  151.     Dim FullName As String
  152.  
  153.     frmPrint.MousePointer = 11 ' hourglass
  154.     If MaxLen = 0 Then InitID
  155.  
  156.     If obSelected.Value = True Then ' Selected files Only
  157.         For i = 0 To frmBrowse!filBrowse.ListCount - 1
  158.             If frmBrowse!filBrowse.Selected(i) Then
  159.                 FullName = frmBrowse!filBrowse.Path + "\" + frmBrowse!filBrowse.List(i)
  160.                 PrintOne (FullName)
  161.             End If
  162.         Next
  163.     Else    ' print all files in directory
  164.         For i = 0 To frmBrowse!filBrowse.ListCount - 1
  165.             FullName = frmBrowse!filBrowse.Path + "\" + frmBrowse!filBrowse.List(i)
  166.             PrintOne (FullName)
  167.         Next
  168.     End If
  169.     
  170.     Printer.EndDoc
  171.     
  172.     frmPrint.MousePointer = 0 ' normal
  173.     Unload frmPrint
  174. End Sub
  175.  
  176. Sub Form_Load ()
  177.     frmPrint.Top = PrintTop
  178.     frmPrint.Left = PrintLeft
  179.     lblFont.Caption = Printer.FontName
  180.     lblDir.Caption = frmBrowse!lblCurDir.Caption
  181.     tbTitle.Text = "Version information for directory " + lblDir.Caption
  182.     If frmBrowse!filBrowse.ListIndex < 0 Then ' no files selected
  183.         obSelected.Enabled = False ' disable "Selected Files"
  184.         obDirectory.Value = True ' Force "Entire Directory"
  185.     End If
  186. End Sub
  187.  
  188. Sub Form_Unload (Cancel As Integer)
  189.     PrintTop = frmPrint.Top
  190.     PrintLeft = frmPrint.Left
  191. End Sub
  192.  
  193. Sub InitID ()
  194.     Dim i As Integer
  195.     Static BeenHere As Integer
  196.  
  197.     If Not BeenHere Then
  198.         IDs(0) = "Name: "
  199.         IDs(1) = "Last Modified: "
  200.         IDs(2) = "Size: "
  201.         IDs(3) = "Description: "
  202.         IDs(4) = "File Version: "
  203.         IDs(5) = "Company Name: "
  204.         IDs(6) = "Language: "
  205.         IDs(7) = "Original Name: "
  206.         IDs(8) = "Internal Name: "
  207.         IDs(9) = "Comments: "
  208.         IDs(10) = "Copyright: "
  209.         IDs(11) = "Trademarks: "
  210.         IDs(12) = "Product Name: "
  211.         IDs(13) = "Product Version: "
  212.         IDs(14) = "Special Build: "
  213.         IDs(15) = "Private Build: "
  214.         BeenHere = True
  215.     End If
  216.  
  217.     For i = 0 To 15
  218.         IDLen(i) = Printer.TextWidth(IDs(i))
  219.         If IDLen(i) > MaxLen Then MaxLen = IDLen(i)
  220.     Next
  221.     LineHeight = Printer.TextHeight("X")
  222. End Sub
  223.  
  224. Sub PrintOne (FullName As String)
  225.     Dim VerInfoPresent As Integer
  226.     Dim VI As VerInfo
  227.     Dim PageNo As String
  228.     Dim TotHeight As Integer
  229.     Static CurDateTime As String
  230.  
  231.     If CurDateTime <= " " Then
  232.         CurDateTime = Format(Now, "dddd, mmmm d, yyyy \a\t h:mm AM/PM")
  233.     End If
  234.     VerInfoPresent = GetFileVersion(FullName, VI)
  235.     If VerInfoPresent Then ' compute height of into to be printed
  236.         TotHeight = 17 * LineHeight
  237.     Else
  238.         TotHeight = 4 * LineHeight
  239.     End If
  240.     If (Printer.CurrentY + TotHeight + 1) > Printer.ScaleHeight Then Printer.NewPage
  241.     
  242.     If Printer.CurrentY = 0 Then ' top of page
  243.         Printer.Print ' leave some top margin
  244.         Printer.Print CurDateTime;
  245.         PageNo = "Page:" + Str$(Printer.Page)
  246.         Printer.CurrentX = Printer.ScaleWidth - Printer.TextWidth(PageNo)
  247.         Printer.Print PageNo
  248.         Printer.Print tbTitle
  249.     End If
  250.  
  251.     Printer.CurrentY = Printer.CurrentY + (LineHeight / 2)
  252.     Printer.Line (Printer.CurrentX, Printer.CurrentY)-(Printer.ScaleWidth, Printer.CurrentY)
  253.     Printer.CurrentY = Printer.CurrentY + (LineHeight / 2)
  254.     
  255.     Printer.CurrentX = MaxLen - IDLen(0)
  256.     Printer.Print IDs(0);
  257.     Printer.FontBold = True
  258.     Printer.Print FullName
  259.     Printer.FontBold = False
  260.     
  261.     Printer.CurrentX = MaxLen - IDLen(1)
  262.     Printer.Print IDs(1); Format$(FileDateTime(FullName), "dddd, mmmm d, yyyy \a\t h:mm AM/PM")
  263.  
  264.     Printer.CurrentX = MaxLen - IDLen(2)
  265.     Printer.Print IDs(2); Format$(FileLen(FullName), "###,###,###,##0 \b\y\t\e\s")
  266.  
  267.     If Not VerInfoPresent Then Exit Sub ' no Version info available
  268.  
  269.     Printer.CurrentX = MaxLen - IDLen(3)
  270.     Printer.Print IDs(3); VI.FileDescription
  271.     
  272.     Printer.CurrentX = MaxLen - IDLen(4)
  273.     Printer.Print IDs(4); VI.FileVersion
  274.     
  275.     Printer.CurrentX = MaxLen - IDLen(5)
  276.     Printer.Print IDs(5); VI.CompanyName
  277.     
  278.     Printer.CurrentX = MaxLen - IDLen(6)
  279.     Printer.Print IDs(6); VI.Language
  280.     
  281.     Printer.CurrentX = MaxLen - IDLen(7)
  282.     Printer.Print IDs(7); VI.OriginalFileName
  283.     
  284.     Printer.CurrentX = MaxLen - IDLen(8)
  285.     Printer.Print IDs(8); VI.InternalName
  286.     
  287.     Printer.CurrentX = MaxLen - IDLen(9)
  288.     Printer.Print IDs(9); VI.Comments
  289.     
  290.     Printer.CurrentX = MaxLen - IDLen(10)
  291.     Printer.Print IDs(10); VI.LegalCopyright
  292.     
  293.     Printer.CurrentX = MaxLen - IDLen(11)
  294.     Printer.Print IDs(11); VI.LegalTrademarks
  295.     
  296.     Printer.CurrentX = MaxLen - IDLen(12)
  297.     Printer.Print IDs(12); VI.ProductName
  298.     
  299.     Printer.CurrentX = MaxLen - IDLen(13)
  300.     Printer.Print IDs(13); VI.ProductVersion
  301.     
  302.     Printer.CurrentX = MaxLen - IDLen(14)
  303.     Printer.Print IDs(14); VI.SpecialBuild
  304.     
  305.     Printer.CurrentX = MaxLen - IDLen(15)
  306.     Printer.Print IDs(15); VI.PrivateBuild
  307. End Sub
  308.  
  309.